package com.lmy.comeposedemo

import android.os.Bundle
import android.widget.Toast
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.foundation.Image
import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.Button
import androidx.compose.material.Text
import androidx.compose.material.TextField
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.unit.dp
import coil.compose.rememberImagePainter
import coil.transform.CircleCropTransformation

class MainActivity : ComponentActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContent {
//            Image(painter = , contentDescription ="sss")
            val painter =
                rememberImagePainter(data = "https://upload-images.jianshu.io/upload_images/7589697-e5837158837c1f3d.jpg?imageMogr2/auto-orient/strip|imageView2/2/format/webp",
                    builder = {
                        transformations(CircleCropTransformation())
                    })
            Column(
                Modifier
                    .background(Color.Red, RoundedCornerShape(10.dp))
                    .padding(8.dp)
            ) {
                Text(text = "22222", Modifier.clickable {
                    Toast.makeText(this@MainActivity, "111", Toast.LENGTH_SHORT).show()
                })
                Image(
                    painter = painterResource(id = R.drawable.ic_launcher_background),
                    contentDescription = "",
                    modifier = Modifier
                        .size(100.dp)
                        .clip(RoundedCornerShape(10.dp))
                        .clickable {
                            Toast
                                .makeText(this@MainActivity, "Image", Toast.LENGTH_SHORT)
                                .show()
                        },
                )
                Button(modifier = Modifier.padding(0.dp, 20.dp, 0.dp, 0.dp), onClick = {
                    Toast
                        .makeText(this@MainActivity, "Image", Toast.LENGTH_SHORT)
                        .show()
                }) {
                    Column(Modifier.padding(0.dp)) {
                        Text(text = "22222", Modifier.clickable {
                            Toast.makeText(this@MainActivity, "111", Toast.LENGTH_SHORT).show()
                        })
                        Image(
                            painter = painterResource(id = R.drawable.ic_launcher_background),
                            contentDescription = "sss"
                        )
                        val lisrString = listOf("1", "2", "3", "4")
                        LazyColumn {
                            items(lisrString) { item ->
                                Text(text = item)
                            }
                        }

                        TextField(value = "111", onValueChange = {
                            Toast.makeText(this@MainActivity, it, Toast.LENGTH_SHORT).show()
                        })
                    }
                }
            }
        }
    }
}

